#!/usr/bin/python
# -*- coding:utf-8 -*-

import threading
import urllib2
import time
import random

def my_function(url, tid):
    while True:
        res = urllib2.urlopen(url)
        print tid,res.msg + "|" + url
        time.sleep(random.randint(1,5))

url = "http://www.baidu.com"
t_count = 30  #变量，线程数为10

for i in range(0, t_count):
    t = threading.Thread(target=my_function, args=(url,i))
    t.start()
